﻿using System;

namespace BaseSyntax.OperatorTest
{
	public class NullOperation:ITest
	{
		void NullMerge()
		{
			string str1 = null;
			string str2 = "sss";
			string str3 = str1 ?? str2;
			// sss
			Console.WriteLine(str3);
		}

		void Nullable()
		{
			int? a = null;
		}

		void NullCondition()
		{
			string str = null;

			// length为空
			Console.WriteLine($"aaa {str?.Length}");
			if (str?.Length == 0)
			{
				Console.WriteLine("no null");
			}
			else
			{
				Console.WriteLine("null");
			}
			
			// 空条件操作符与索引
			string[] arr = new string[3];
			string str1 = arr?[0];
			
		}
		
		public void Test()
		{

			NullCondition();
		}
	}
}